<template>
  <base-breadcrumb>
    <searchData :search-data="searchArr" @search="search" />
    <a-card>
<!--      <a-button type="primary" @click="generate" class="mb20">生成</a-button>-->
      <list-table
        ref="table"
        :pageKeys="['pageNum', 'pageSize', 'total']"
        :columns="columns"
        :request="loadData"
      >
        <template slot="index" slot-scope="text, record, index">{{ index + 1 }}</template>
        <div slot="operation" slot-scope="text, record, index">
          <a v-btn-permission="'hse_030_loo_04'" @click="$nav('monthReportDetail',{id:record.id})">查看</a>
        </div>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>
<script>

import { getPageSafetyMonthReport, insertSelective } from '@/api/safetySupervision/other/monthReport'

export default {
  name: 'index',
  components: {},
  props: {
    modelValue: false
  },
  data() {
    return {
      searchArr: [
        {
          name: '月份',
          value: 'month',
          type: 'month'
        }
      ],
      columns: [
        {
          title: '序号',
          width: 70,
          scopedSlots: { customRender: 'index' }
        },
        {
          title: '月份',
          dataIndex: 'month'
        },
        {
          title: '操作',
          width: 240,
          scopedSlots: { customRender: 'operation' }
        }
      ],
      searchParams: {},
      loadData: async p => {
        let res = await getPageSafetyMonthReport({}, Object.assign(p, { param: { ...this.searchParams } }))
        if (res.code === 200) {
          return { code: 200, data: res.data.list, ...res.data }
        }
        return { code: 500 }
      }
    }
  },
  computed: {},
  watch: {},
  created() {
  },
  methods: {
    async generate() {
      let res  = await insertSelective()
      if (res.code === 200){
        this.$noticeSuccess('生成成功')
        this.$refs.table.refresh()
      }
    },
    search(val) {
      this.searchParams = val
      this.$refs.table.refresh()
    }
  }
}
</script>
